package org.xx.armory.spring5.autoconfigure;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.xx.armory.spring5.DateConverter;

@Configuration
@ConditionalOnWebApplication
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
public class ArmoryUtilsAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public DateConverter dateConverter(
            @Value("${armory.zone:}") String offset
    ) {
        return new DateConverter(offset);
    }
}
